package com.qijian.production.domain.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qijian.common.annotation.Excel;
import com.qijian.common.utils.uuid.IdUtils;
import com.qijian.production.domain.PointOrderItem;
import com.qijian.production.domain.PointOrderItemDetail;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@ToString
public class PointOrderItemVo extends PointOrderItem {


    @Excel(name = "工单编码")
    private String workCode;

    private List<PointOrderItemDetail> details;

    @JsonSerialize(using= ToStringSerializer.class)
    private Long managerId;

    private String managerName;

    private String workOrderDetailNo;

    public List<PointOrderItemDetail> initDetailMain(Long mainId) {
        super.setId(IdUtils.singletonSnowId());
        super.setMainId(mainId);
        this.details.forEach(d -> {
            d.setId(null);
            d.setMainId(this.getMainId());
            d.setMainItemId(this.getId());
        });
        return this.getDetails();
    }

}
